<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta content="width=device-width, initial-scale=1" name="viewport">
  <meta content="ie=edge" http-equiv="X-UA-Compatible">
  <title>geolocation</title>
</head>
<body>
  <div id="o"></div>
<script>
  let o = document.getElementById('o');
  navigator.geolocation.getCurrentPosition((s) => {
    o.innerText = s.coords.latitude.toFixed(6);
  }, (e) => {
    e.innerText = s.coords.latitude.toFixed(6);
  })
</script>
</body>
</html>
